/**
 * Created by Zhouxiumin on 2017/3/28.
 */

export class BaseParser {
  readonly baseUrl: string = '';
  readonly name: string ='base';
  readonly intro:string = '基础类，不是具体的解析类';
  readonly expr:string = 'XXX\.XXX\.XXX';
  readonly tags:Array<{title:string,url:string}> = [];
  readonly searchUrl = '';

  constructor() {
  }

  public hots_parse(url, html) {
    console.log('hot_parse');
    return JSON.stringify([])
  }

  public tags_parse(url, html) {
    console.log('tags_parse');
    return JSON.stringify([])
  }

  public book_parse(url, html) {
    console.log('book_parse');
    return JSON.stringify({})
  }

  public section_parse(url, html) {
    console.log('section_parse');
    return JSON.stringify([])
  }

  public search_parse(url, html) {
    console.log('search_parse');
    return JSON.stringify([])
  }

  public urla(u) {
    let host = this.baseUrl;
    if (u.indexOf("http") < 0) {
      if (u.substr(0, 1) != '/')
        u = host + '/' + u;
      else
        u = host + u;
    }
    return encodeURI(u);
  }

  public getBaseUrl(){
    return this.baseUrl;
  }

  public getName(){
    return this.name;
  }

  public getIntro(){
    return this.intro;
  }

  public getExpr(){
    return this.expr;
  }

  public getTags(){
    return this.tags;
  }

}
